package cn.ctodb.cms.service.mapper;

import cn.ctodb.cms.domain.*;
import cn.ctodb.cms.service.dto.CmsTxtDTO;

import org.mapstruct.*;
import java.util.List;

/**
 * Mapper for the entity CmsTxt and its DTO CmsTxtDTO.
 */
@Mapper(componentModel = "spring", uses = {})
public interface CmsTxtMapper {

    @Mapping(source = "cmsChannel.id", target = "cmsChannelId")
    @Mapping(source = "cmsContent.id", target = "cmsContentId")
    CmsTxtDTO cmsTxtToCmsTxtDTO(CmsTxt cmsTxt);

    List<CmsTxtDTO> cmsTxtsToCmsTxtDTOs(List<CmsTxt> cmsTxts);

    @Mapping(source = "cmsChannelId", target = "cmsChannel")
    @Mapping(source = "cmsContentId", target = "cmsContent")
    CmsTxt cmsTxtDTOToCmsTxt(CmsTxtDTO cmsTxtDTO);

    List<CmsTxt> cmsTxtDTOsToCmsTxts(List<CmsTxtDTO> cmsTxtDTOs);

    default CmsChannel cmsChannelFromId(Long id) {
        if (id == null) {
            return null;
        }
        CmsChannel cmsChannel = new CmsChannel();
        cmsChannel.setId(id);
        return cmsChannel;
    }

    default CmsContent cmsContentFromId(Long id) {
        if (id == null) {
            return null;
        }
        CmsContent cmsContent = new CmsContent();
        cmsContent.setId(id);
        return cmsContent;
    }
}
